﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IterationLife.Domains.Sports.Models;

namespace IterationLife.Domains.Sports.Dtos.MTSports
{
    /// <summary>
    /// 事件
    /// </summary>
    public class MTEvent
    {
        /// <summary>
        /// 队伍id
        /// </summary>
        public int team_id { get; set; }
        /// <summary>
        /// 比赛id
        /// </summary>
        public int event_id { get; set; }
        /// <summary>
        /// 1:比赛 2：训练
        /// </summary>
        public int type { get; set; }
        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime start_time { get; set; }
        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime end_time { get; set; }
        /// <summary>
        /// 天气
        /// </summary>
        public string weather { get; set; }
        /// <summary>
        /// 球场
        /// </summary>
        public string field_name { get; set; }
        /// <summary>
        /// GPS地址
        /// </summary>
        public string field_place { get; set; }
        /// <summary>
        /// 地形
        /// </summary>
        public string grass_type { get; set; }
        /// <summary>
        /// 比赛人数
        /// </summary>
        public int person_cnt { get; set; }
        /// <summary>
        /// 地址信息
        /// </summary>
        //public MTArea area_info { get; set; }
        /// <summary>
        /// 温度
        /// </summary>
        public string humidity { get; set; }
        /// <summary>
        /// 湿度
        /// </summary>
        public string temperature { get; set; }
    }

    /// <summary>
    /// 扩展
    /// </summary>
    public static class MTEventExtension
    {
        public static SportEvent ToSportEvent(this MTEvent item)
        {
            var result = new SportEvent(Guid.NewGuid());
            SetEntity(result, item);
            return result;
        }

        public static void SetEntity(SportEvent sportEvent, MTEvent item)
        {
            sportEvent.PartnerEventId = item.event_id.ToString();
            sportEvent.EventType = item.type;
            sportEvent.StartTime = item.start_time;
            sportEvent.EndTime = item.end_time;
            sportEvent.Weather = item.weather;
            sportEvent.Humidity = item.humidity;
            sportEvent.Temperature = item.temperature;
            sportEvent.GrassType = item.grass_type;
            sportEvent.PersonCnt = item.person_cnt;
            sportEvent.FieldPlace = item.field_place;
            sportEvent.FieldName = item.field_name;
        }
    }
}
